package com.atguigu.spzx.cloud.order.Interceptor;

import com.atguigu.spzx.cloud.order.utils.MyAuthThreadLocal;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * BelongProject: springCloud
 * BelongPackage: com.atguigu.spzx.cloud.order.Interceptor
 * Description:
 *
 * @Author 段鑫涛
 * @Create 2025/5/26 21:15
 * @Version 1.0
 */
@Component
public class AuthInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //将鉴权结果方法哦本地存储到ThreadLocal中
        String truth = request.getHeader("Truth");
        MyAuthThreadLocal.threadLocal.set(truth);
        return true;
    }
}
